package io.output_stream;


import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class ByteArrayOutputStreamTest {


    private static final int LEN = 5;
     // 对应英文字母“abcddefghijklmnopqrsttuvwxyz”
     private static final byte[] ArrayLetters = {
             0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
             0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A
         };

     public static void main(String[] args) throws IOException {
         //String tmp = new String(ArrayLetters);
         //System.out.println("ArrayLetters="+tmp);

         tesByteArrayOutputStream() ;
     }

     public static void tesByteArrayOutputStream() throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         baos.write(0x41);
         baos.write(0x42);
         baos.write(0x43);
         System.out.println(baos);
         System.out.println("---------------");

         byte[] bytes = baos.toByteArray();
         System.out.println(new String(bytes));

         System.out.println("_______________");
         ByteArrayOutputStream baos2 = new ByteArrayOutputStream();

         baos.writeTo(baos2);
         System.out.println(baos2);


     }
}
